package flc.ast.dataBase;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

import flc.ast.bean.Album;
import flc.ast.bean.Image;

@Dao
public interface AlbumDao {
    // 相册操作
    @Insert
    long insertAlbum(Album album);
    @Update
    void updateAlbum(Album album);
    @Delete
    void deleteAlbum(Album album);
    @Query("SELECT * FROM albums")
    List<Album> getAllAlbums();

    // 图片操作
    @Insert
    void insertImage(Image image);
    @Update
    void updateImage(Image image);
    @Delete
    void deleteImage(Image image);
    @Query("SELECT * FROM images")
    List<Image> getAllImages();

    //查询指定相册下的所有图片
    @Query("SELECT * FROM images WHERE albumId = :albumId")
    List<Image> getImagesByAlbumId(int albumId);
    
    // 修改收藏状态和标签
    @Query("UPDATE images SET isFavorite = :isFavorite WHERE id = :imageId")
    void setFavorite(int imageId, boolean isFavorite);
    @Query("UPDATE images SET tags = :tags WHERE id = :imageId")
    void updateTags(int imageId, String tags);
}
